package com.qf.userfull;

import java.util.Objects;

/**
 * abstract 关键字，可以添加在类的前面，作用：当前类就是抽象类了，抽象类不能通过 new 的方式被创建对象
 */
public abstract class Animal {

    private String breed;

    private String sex;

    private int age;

    // 攻击力
    private int atk;

    // 添加hp属性，用来判断当前对象是否存活
    private int hp;

    public Animal() {
    }

    public Animal(String breed, String sex, int age, int atk, int hp) {
        this.breed = breed;
        this.sex = sex;
        this.age = age;
        this.atk = atk;
        this.hp = hp;
    }

    public int getAtk() {
        return atk;
    }

    public void setAtk(int atk) {
        this.atk = atk;
    }

    public int getHp() {
        return hp;
    }

    public void setHp(int hp) {
        this.hp = hp;
    }

    public String getBreed() {
        return breed;
    }

    public void setBreed(String breed) {
        this.breed = breed;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }


    public abstract void sleep();

    public abstract void eat();

//    public static abstract  void test1(); // 错误


    public static void test1(){
        System.out.println("test1");
    }

    @Override
    public String toString() {
        return "Animal{" +
                "breed='" + breed + '\'' +
                ", sex='" + sex + '\'' +
                ", age=" + age +
                ", atk=" + atk +
                ", hp=" + hp +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Animal animal = (Animal) o;
        return age == animal.age && atk == animal.atk && hp == animal.hp && breed.equals(animal.breed) && sex.equals(animal.sex);
    }

}
